﻿Public Class TB_PRUEBA_DISENO

    Public Shared Sub ACTUALIZA_PRUEBA_DISENNO( _
        ByRef Rp As DotNetResponse.SQLPersistence, _
        ByRef Exec As DotNetDal.SQLPersistence, _
        ByVal ID_PRUEBA As Long, _
        ByVal FK_PROFESOR As Long, _
        ByVal FK_CURSO As Long, _
        ByVal NRO_SECCIONES As Integer, _
        ByVal CODIGO_PRUEBA As String, _
        ByVal NOMBRE_PRUEBA As String, _
        ByVal FECHA_PRUEBA As String, _
        ByVal ESTADO As String, _
        ByVal ANIO As Integer, _
        ByVal PERIODO As Integer, _
        ByVal usuario As String)

        Dim LocalCommit As Boolean = False
        Dim Rpexec As New DotNetResponse.SQLPersistence
        Rpexec.StoredProcedure = "SP_ACTUALIZA_PRUEBA_DISENNO"
        If Exec Is Nothing Then
            Exec = New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
            LocalCommit = True
        End If

        Rpexec.AddParametro(ID_PRUEBA)
        Rpexec.AddParametro(FK_PROFESOR)
        Rpexec.AddParametro(FK_CURSO)
        Rpexec.AddParametro(NRO_SECCIONES)
        Rpexec.AddParametro(CODIGO_PRUEBA)
        Rpexec.AddParametro(NOMBRE_PRUEBA)
        Rpexec.AddParametro(FECHA_PRUEBA)
        Rpexec.AddParametro(ESTADO)
        Rpexec.AddParametro(ANIO)
        Rpexec.AddParametro(PERIODO)

        Exec.ExecuteNonQuery(Rpexec)
        If LocalCommit Then
            Exec.Commit()
            Exec.Dispose()
        End If

        Rp.Errores = Rpexec.Errores
        Rp.MensajeError = Rpexec.MensajeError

    End Sub
    Public Shared Sub CREAR_PRUEBA_DISENNO( _
        ByRef Rp As DotNetResponse.SQLPersistence, _
        ByRef Exec As DotNetDal.SQLPersistence, _
           ByVal P_PRUEBA As Long _
         , ByVal S_CODIGO_PRUEBA As String _
         , ByVal I_NRO_SECCIONES As String _
         , ByVal S_NOMBRE_PRUEBA As String _
         , ByVal S_OBSERVACION As String _
         , ByVal S_AUD_USUARIO_C As String _
         , ByVal S_ESTADO As String _
         , ByVal D_AUD_FECHA_C As String _
         , ByVal D_AUD_FECHA_M As String _
         , ByVal S_AUD_USUARIO_M As String _
    )

        Dim LocalCommit As Boolean = False
        Dim Rpexec As New DotNetResponse.SQLPersistence
        Rpexec.StoredProcedure = "SP_CREAR_PRUEBA_DISENNO"
        If Exec Is Nothing Then
            Exec = New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
            LocalCommit = True
        End If

        Rpexec.AddParametro(P_PRUEBA)
        Rpexec.AddParametro(S_CODIGO_PRUEBA)
        Rpexec.AddParametro(I_NRO_SECCIONES)
        Rpexec.AddParametro(S_NOMBRE_PRUEBA)
        Rpexec.AddParametro(S_OBSERVACION)
        Rpexec.AddParametro(S_AUD_USUARIO_C)
        Rpexec.AddParametro(S_ESTADO)
        Rpexec.AddParametro(D_AUD_FECHA_C)
        Rpexec.AddParametro(D_AUD_FECHA_M)
        Rpexec.AddParametro(S_AUD_USUARIO_M)

        Exec.ExecuteScalar(Rpexec)
        If LocalCommit Then
            Exec.Commit()
            Exec.Dispose()
        End If

        Rp.MensajeError = Rpexec.MensajeError
        Rp.GetScalar = Rpexec.GetScalar
        Rp.Errores = Rpexec.Errores


    End Sub
    Public Shared Sub ELIMINA_PRUEBA_DISENNO(ByRef Rp As DotNetResponse.SQLPersistence, ByRef Exec As DotNetDal.SQLPersistence, ByVal ID_PRUEBA As Long, ByVal usuario As String)
        Dim LocalCommit As Boolean = False
        Dim Rpexec As New DotNetResponse.SQLPersistence
        Rpexec.StoredProcedure = "SP_ELIMINA_PRUEBA_DISENNO"
        If Exec Is Nothing Then
            Exec = New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
            LocalCommit = True
        End If
        Rpexec.AddParametro(ID_PRUEBA)

        Exec.ExecuteNonQuery(Rpexec)
        If LocalCommit Then
            Exec.Commit()
            Exec.Dispose()
        End If

        Rp.MensajeError = Rpexec.MensajeError
        Rp.GetScalar = Rpexec.GetScalar
        Rp.Errores = Rpexec.Errores

    End Sub
    Public Shared Sub SELECCIONA_PRUEBA_DISENNO_PK(ByRef Rp As DotNetResponse.SQLPersistence, ByRef Exec As DotNetDal.SQLPersistence, ByVal ID_PRUEBA As Long, ByVal usuario As String)
        Dim LocalCommit As Boolean = False
        Dim Rpexec As New DotNetResponse.SQLPersistence
        'Rpexec.StoredProcedure = "SP_SELECCIONA_PRUEBA_DISENNO_PK"

        Dim csql As String = "select S_NOMBRE_PRUEBA, S_OBSERVACION  ,  I_NRO_SECCIONES  from  TB_PRUEBA_DISENO where P_PRUEBA =" & ID_PRUEBA
        If Exec Is Nothing Then
            Exec = New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
            LocalCommit = True
        End If

        'Rpexec.AddParametro(ID_PRUEBA)

        Exec.ExecuteDataTable(Rpexec, csql)
        If LocalCommit Then
            Exec.Commit()
            Exec.Dispose()
        End If

        Rp.DtTable = Rpexec.DtTable
        Rp.Errores = Rpexec.Errores
        Rp.MensajeError = Rpexec.MensajeError
    End Sub

End Class
